//
//  dataViewController.m
//  选取器
//
//  Created by student on 16/2/23.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "dataViewController.h"

@interface dataViewController ()

@end

@implementation dataViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)datachange:(id)sender
{
    NSDate *now = [NSDate date];
    
    NSTimeInterval t = [now timeIntervalSinceDate:self.datapicker.date];
    self.label.text = [NSString stringWithFormat:@"你所选的时间和当前时间的间隔%g天",fabs(t/60.0/60.0/24.0)];
    
}

- (IBAction)btnpressed:(id)sender
{
    NSDateFormatter *f = [[NSDateFormatter alloc] init];
    [f setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *str = [f stringFromDate:self.datapicker.date];
    
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"你所选的时间是" message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alertView show];
    
    
    
}
@end
